<!DOCTYPE html>
<html>
	<head>
		<title>修改信息</title>
		<meta http-equiv="Pragma" CONTENT="no-cache">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="renderer" content="webkit">

		<%include("/common/include.html"){}%>
	</head>
	<body>

<form id="bentryForm"   method="post"  enctype="multipart/form-data">
				
				<table border="0"  style=" width: 100%">
					
						
					<tr>
					<td colspan="8">
						<HR style="" width="100%" color=#ff954e SIZE=3 />
					</td>
					</tr>
					<tr >
						<td align="right" >姓名</td>
						<td style=" width: 180px">
							<input id="customerIds" name="customer.ids" type="hidden" value="${customer.ids! }"/>
							<input id="customerName" name="customer.name" class="easyui-textbox inputBox theme-textbox-radius"   style="width: 150px;" value="${customer.name! }">
						</td>
						<td align="right">性别</td>
						<td>
							<input  class="easyui-textbox theme-textbox-radius" readonly="true" style="width: 150px;" value="${customer.sex! }">
						</td>
					<td align="right">手机号码</td>
						<td >
							<input id="customerPhone" name="customer.phone" class="easyui-textbox theme-textbox-radius"  style="width: 150px;" value="${customer.phone! }">
						</td> 
					</tr>
					<tr>
						<td align="right">年龄</td>
						<td>
							<input  class="easyui-textbox theme-textbox-radius"  readonly="true" value="${customer.age! }" style="width: 150px;" data-options="increment:1,label:'岁'" labelPosition="after">
						</td>
						<td align="right">身高</td>
						<td style="width: 125px;">
							<input  class="easyui-textbox theme-textbox-radius"  readonly="true"  value="${customer.customerDetail.height! }" style="width: 149px;" data-options="increment:1,label:'cm'" labelPosition="after">
						</td>
						<td align="right">首次进店体重</td>
						<td width="200px" >
							<input  class="easyui-textbox theme-textbox-radius"  readonly="true"  value="${customer.customerDetail.firstWeight! }" style="width: 150px;" data-options="increment:1,label:'斤'" labelPosition="after">
						</td>
					</tr>
					 <tr>
					 
					 <td align="right">应减斤数</td>
						<td>
							<input id="delWeight"  readonly="true"  class="easyui-textbox theme-textbox-radius"   readonly="true" style="width: 150px;" value="${customer.customerDetail.delWeight !}">
						</td>
						
						<td align="right">首次进店日期</td>
						<td>
							<input id="firstDate"  name="customerDetail.firstDate"  class="easyui-datebox theme-textbox-radius" style="width: 150px;" value="${customer.customerDetail.firstDate !}">
						</td>
						
					
						<td align="right">产品编号</td>
						<td>
							<input id="firstDate"  name="customerDetail.productNo"  class="easyui-textbox theme-textbox-radius"  style="width: 150px;" value="${customer.customerDetail.productNo! }">
						</td>
					
						
					</tr>
					<tr>
						<td align="right">身份证号</td>
						<td>
							<input name="customer.sfzmhm" class="easyui-textbox theme-textbox-radius"   style="width: 150px;" value="${customer.sfzmhm! }">
						</td> 
						<td align="right">生日</td>
						<td>
							<input name="customerDetail.birth" class="easyui-datebox theme-textbox-radius" style="width: 150px;" data-options="sharedCalendar:'#cc'" value="${customer.customerDetail.birth! }">
						</td>
						<td align="right">职业</td>
						<td>
							<input name="customerDetail.job" class="easyui-textbox theme-textbox-radius"  style="width: 150px;"  value="${customer.customerDetail.job! }">
						</td>
					</tr>
					<div id="cc" class="easyui-calendar"></div>
					
					<tr>
						
						<td align="right" width="150px">购买疗程</td>
						<td>	
								<input  class="easyui-textbox theme-textbox-radius"   readonly="true"  style="width: 150px;"  value="${lcName! }">
						</td>
						<td align="right" >购买疗程数</td>
						<td>
							<input id="cusAgree_treatment"  readonly="true"   class="easyui-textbox theme-textbox-radius" style="width: 150px;" value="${customer.customerAgreement.treatment !}">
						</td>
						<td align="right" >消费金额</td>
						<td>
							<input id="cusAgree_cost"  readonly="true" class="easyui-textbox theme-textbox-radius" style="width: 150px;" value="${customer.customerAgreement.cost !}">
						</td>
					</tr>
					<tr>
						
						
						<td align="right">负责人</td>
						<td>
							<#organization type="select" id="fzr" name="customerDetail.chargePersion"  defaultCode="${customer.customerDetail.chargePersion !}"   class="easyui-combobox inputBox theme-textbox-radius" organization="${organids! }" style="width:150px;"/>
						</td>
					</tr>
					
					<tr>
						<td align="right">联系住址</td>
						<td colspan="5">
							 <#code type="select" id="xzqh_select" name="customerDetail.provice" code="code_xzqh" defaultCode="${customer.customerDetail.provice! }"  class="easyui-combobox inputBox theme-textbox-radius" />
								<input id="city_input" type="hidden" value="${customer.customerDetail.city !}">
								<input id="city_combobox" name="customerDetail.city" class="easyui-combobox inputBox theme-textbox-radius" />
								<input id="area_input" type="hidden" value="${customer.customerDetail.area !}">
								<input id="area_combobox" name="customerDetail.area" class="easyui-combobox inputBox theme-textbox-radius"/>
								<input class="easyui-textbox theme-textbox-radius" name="customerDetail.address" style="width: 140px;" value="${customer.customerDetail.address !}">
						</td>
					</tr>
					<!-- <tr>
						<td align="right">
							<a href="#" class="easyui-linkbutton" style="background: #00A65A;color: white;" onclick="chakan(1)">查看</a>
						</td>
						<td colspan="2">	
							<input id="zmfile"  name="zmfile"  class="easyui-filebox theme-textbox-radius"  onchange="imagePreview(this,1)"  style="width:250px" data-options="buttonText:'正面上传照',prompt:'请选择文件...'">					
						</td>	
							
						<td colspan="3" align="right">	
								<a href="#" class="easyui-linkbutton" style="background: #00A65A;color: white;" onclick="chakan(2)">查看</a>					
							<input id="cmfile"  name="cmfile" class="easyui-filebox theme-textbox-radius" onchange="imagePreview(this,2)" style="width:250px" data-options="buttonText:'侧面上传照',prompt:'请选择文件...'">		
						</td>
						
					</tr> -->
					
					<!-- <tr>
						<td  align="right">
						<a href="#" class="easyui-linkbutton" style="background: #00A65A;color: white;" onclick="chakan(1)">正面查看</a>
						</td>
						<td colspan="2">	
						<input id="zmfile"  name="zmfile"  type="file"  onchange="imgPreview()"    accept="image/jpeg,image/png,image/gif"  >		
						<input id="zmfile"  name="zmfile" class="easyui-filebox"    accept="image/jpeg,image/png,image/gif"  style="width:250px" data-options="onChange:function(){upload()}, buttonText:'正面上传照',prompt:'请选择文件...'">		
						</td>		
							
						<td colspan="3">	
						<a href="#" class="easyui-linkbutton" style="background: #00A65A;color: white;" onclick="chakan(2)">侧面查看</a>					
						<input id="cmfile"  name="cmfile" type="file"  onchange="imgPreview1()"  accept="image/jpeg,image/png,image/gif"  >		
						<input id="cmfile"  name="cmfile" class="easyui-filebox"   accept="image/jpeg,image/png,image/gif"  style="width:250px" data-options="onChange:function(){upload()},buttonText:'侧面上传照',prompt:'请选择文件...'">		
						</td>
					</tr> -->
					
					<tr>
						<td style="height: 25px;"></td><td style="height: 25px;"></td>
						<td style="height: 25px;"></td><td style="height: 25px;"></td>
						<td style="height: 25px;"></td>
					</tr>
					<tr>
					<td  align="center">
						<a href="#" class="easyui-linkbutton" style="background: #00A65A;color: white;" onclick="update()">确认修改</a>
						</td>
						</tr>
				</table>
			</form>
			
			<script src="${cxt !}/sb/js/ajaxfileupload.js" type="text/javascript" charset="utf-8"></script>
		<script src="${cxt !}/sb/js/jquery.form.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
		$(document).ready(function () {
			
			
			
			
			
			//省份改变选择城市
			$('#xzqh_select').combobox({

				onChange: function (n,o) {
					
					
					getCity(n);
				},
			onSelect: function (n) 
			 {		
				 var newPtion = $('#xzqh_select').combobox('getValue');
				 getCity(newPtion);
			 }

			});
			//市改变选择区
			$('#city_combobox').combobox({

				onChange: function (n,o) {
					getArea(n);
				}
				
			});
			
			

		});
		
	
		//获取城市
		function  getCity(n)
		{
			
			var url = "/bentryRegister/getChild";
			var data={"codeIds":n};
			var reData = common_ajax.ajaxFunc(url,data,"json");
			var city=$("#city_input").val();
			var com=$('#city_combobox');
			
			select(reData,com,city);
		}
		//获取区
		function  getArea(n)
		{
			var url = "/bentryRegister/getChild";
			var data={"codeIds":n};
			var reData = common_ajax.ajaxFunc(url,data,"json");
			var area=$("#area_input").val();
			var com=$('#area_combobox');
			select(reData,com,area);
		}
		function select(reData,com,info)
		{	
			com.combobox({
				  data:reData,
				  valueField:'ids', 
	          	  textField:'name',
		          onLoadSuccess: function () {
		        	  if(info!="")
						 {
							 var val = $(this).combobox('getData'); 
		        	  		  for(var i=0;i<val.length;i++)
		        	  		  {		
		        	  			  if(val[i].ids==info)
		        	  			  {
		        	  				 
		        	  				$(this).combobox('select', val[i].ids); 
		        	  			  }
		        	  		  }
						 }else
						 {
							 var val = $(this).combobox('getData');  
	                         for (var item in val[0]) {  
	                             if (item == 'ids') {  
	                            	
	                                 $(this).combobox('select', val[0][item]);  
	                             }  
	                         } 
						 }
		          }	
	            
			});
			
		}
		
	/* 			
		function imgPreview1(){
	    	var fileDom = document.getElementById("cmfile");
	        //判断是否支持FileReader
	        if (window.FileReader) {
	            var reader = new FileReader();
	        } else {
	            alert("您的设备不支持图片预览功能，如需该功能请升级您的设备！");
	        }
	        //获取文件
	        var file = fileDom.files[0];
	        var imageType = /^image\//;
	        //是否是图片
	        if (!imageType.test(file.type)) {
	            alert("请选择图片！");
	            return false;
	        }
	        //读取完成
	        reader.onload = function(e) {
	            //获取图片dom
	            var img = document.getElementById("cmpicture");
	            //图片路径设置为读取的图片
	            img.src = e.target.result;
	        };
	        reader.readAsDataURL(file);
	       
	        upload('beforecm','cmfile');
	    }
	    
		
		
		
		
		
		
	    function imgPreview(){
	    	var fileDom = document.getElementById("zmfile");
	        //判断是否支持FileReader
	        if (window.FileReader) {
	            var reader = new FileReader();
	        } else {
	            alert("您的设备不支持图片预览功能，如需该功能请升级您的设备！");
	        }
	        //获取文件
	        var file = fileDom.files[0];
	        var imageType = /^image\//;
	        //是否是图片
	        if (!imageType.test(file.type)) {
	            alert("请选择图片！");
	            return false;
	        }
	        //读取完成
	        reader.onload = function(e) {
	            //获取图片dom
	            var img = document.getElementById("zmpicture");
	            //图片路径设置为读取的图片
	            img.src = e.target.result;
	        };
	        reader.readAsDataURL(file);
	       
	        upload('beforezm','zmfile');
	    }
	    
	    
		
		//--------上传图片
		function upload(flag,zp){	
			var customerIds=$('#customerIds').val()+flag;
			 $.ajaxFileUpload({
			        url : '${cxt !}/bentryRegister/imageUpload',   //提交的路径
			        secureuri : false, // 是否启用安全提交，默认为false
			        fileElementId :[zp], // file控件id
//						         fileElementId :'zmfile',
			        dataType : 'json',
			        data : {customerIds : customerIds}, // 键:值，传递文件名
			        success : function(result, status) {
			        	if (result.status == 0) {
			        		$.slideMsg("保存成功", parent.$);
//						                var src = data.src;
//						                $('#show').append("<img src='" + src + "'>");  //显示图片

//						                // 存储已上传图片地址
//						                var oldSrc = $('#pictureSrc').val();
//						                var newSrc = "";
//						                if (oldSrc != "")
//						                    newSrc = oldSrc + ";" + src;
//						                else
//						                    newSrc = src;

//						                $('#pictureSrc').val(newSrc);   //保存路径
			            } 
			        	if(result.status == 1){
			                $.alert(parent.$, result.message);
			            }
			        	if(result.status == 2){
			        		$.slideMsg(result.message, parent.$);
			        	}
			        },
			        error : function(data, status) {
			        	$.alert(parent.$, "只允许上传png,jpg,jpeg,gif,bmp类型的图片文件！");
			        }
			    });
		}
		 */
		
		function  update(){
			
			//保存除宣传品以外的信息
					$.ajax({
		                cache: true,
		                type: "POST",
		                url:"${cxt !}/bentryRegister/updateInfo",
		                data:$('#bentryForm').serialize(),// 你的formid
		                dataType:'json',
		                async: false,
		                success: function(result) {	
		                	
		                	if(result.msg == "修改成功")
		                	{	
		                		$.slideMsg("修改成功", parent.$);
		                		
		                		
		                	}else{		                		
		        					 $.alert(parent.$,result.msg);
		                	}
		                }
		            });
		}
		
		/* function  imagePreview(obj,type){
			
			
					
			var $file =$(obj);
			var fileObj = $file[0];
			var windowURL = window.URL || window.webkitURL;
			
			var dataURL;
			var $img;
			if(type==1){
				$img = $("#zmpicture");
			}
			if(type==2){
				$img = $("#cmpicture");
			}
// 					var $img = $("#zmpicture");
			if(fileObj && fileObj.files && fileObj.files[0]){
				dataURL = windowURL.createObjectURL(fileObj.files[0]);
				$img.attr('src',dataURL);
				
				upload()
			}else{
				dataURL = $file.val();
				var imgObj = document.getElementById("preview");
				// 两个坑:
				// 1、在设置filter属性时，元素必须已经存在在DOM树中，动态创建的Node，也需要在设置属性前加入到DOM中，先设置属性在加入，无效；
				// 2、src属性需要像下面的方式添加，上面的两种方式添加，无效；
				imgObj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
				imgObj.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = dataURL;
			}
		}
		function  chakan(type)
		{
			$('#picture').window('open');
			if(type==1)
			{
				$('#zmpicture').css("display","block");
				$('#cmpicture').css("display","none");
			}
			if(type==2)
			{
				$('#zmpicture').css("display","none");
				$('#cmpicture').css("display","block");
			}
		} */
				
				
		</script>
		</body>
</html>	
			